<% add_decidim_page_title(t("media_links.index.media_links_title", scope: "decidim.admin")) %>
<div class="card" id="media_links">
  <div class="item_show__header">
    <h1 class="item_show__header-title">
      <%= t("media_links.index.media_links_title", scope: "decidim.admin") %>
      <% if allowed_to? :create, :media_link %>
         <%= link_to t("actions.new_media_link", scope: "decidim.admin"), new_conference_media_link_path(current_conference), class: "button button__sm button__secondary new" %>
      <% end %>
    </h1>
  </div>
  <div class="table-stacked">
    <table class="table-list">
      <thead>
        <tr>
          <th><%= t("models.media_link.fields.title", scope: "decidim.admin") %></th>
          <th><%= t("models.media_link.fields.link", scope: "decidim.admin") %></th>
          <th><%= t("models.media_link.fields.date", scope: "decidim.admin") %></th>
          <th><%= t("models.media_link.fields.actions", scope: "decidim.admin") %></th>
        </tr>
      </thead>
      <tbody>
        <% @media_links.each do |media_link| %>
          <tr>
            <td data-label="<%= t("models.media_link.fields.title", scope: "decidim.admin") %>">
              <%= translated_attribute(media_link.title) %>
            </td>
            <td data-label="<%= t("models.media_link.fields.link", scope: "decidim.admin") %>">
              <%= media_link.link %>
            </td>
            <td data-label="<%= t("models.media_link.fields.date", scope: "decidim.admin") %>">
              <%= l(media_link.date, format: :decidim_short ) %>
            </td>
            <td class="table-list__actions" data-label="<%= t("models.media_link.fields.actions", scope: "decidim.admin") %>">
              <button type="button" data-controller="dropdown" data-target="actions-media-link-<%= media_link.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: translated_attribute(media_link.title)) %>">
                <%= icon "more-fill", class: "text-secondary" %>
              </button>

              <div class="inline-block relative">
                <ul id="actions-media-link-<%= media_link.id %>" class="dropdown dropdown__action" aria-hidden="true">
                  <% if allowed_to? :update, :media_link, media_link: media_link %>
                    <li class="dropdown__item">
                      <%= link_to edit_conference_media_link_path(current_conference, media_link), class: "dropdown__button" do %>
                        <%= icon "pencil-line" %>
                        <%= t("actions.edit", scope: "decidim.admin") %>
                      <% end %>
                    </li>

                    <hr>
                  <% end %>

                  <% if allowed_to? :destroy, :media_link, media_link: media_link %>
                    <li class="dropdown__item">
                      <%= link_to conference_media_link_path(current_conference, media_link), method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") }, class: "dropdown__button dropdown__button--danger" do %>
                        <%= icon "delete-bin-line" %>
                        <%= t("actions.destroy", scope: "decidim.admin") %>
                      <% end %>
                    </li>
                  <% end %>
                </ul>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
<%= decidim_paginate @media_links %>
